Skip to content

Add -Zfix-edition #15596

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
May 26, 2025
Merged

Add -Zfix-edition #15596

merged 4 commits into from
May 26, 2025

Conversation

ehuss
Copy link
Contributor

@ehuss ehuss commented May 24, 2025

This adds a new cargo fix -Zfix-edition permanently unstable flag to assist with edition migration testing, particularly with crater.

The commits and given documentation should explain how it works, but there will be forthcoming edition documentation (on the forge) once all the pieces with crater come together.

@rustbot rustbot added A-cli Area: Command-line interface, option parsing, etc. A-documenting-cargo-itself Area: Cargo's documentation A-manifest Area: Cargo.toml issues A-unstable Area: nightly unstable support A-workspaces Area: workspaces Command-fix labels May 24, 2025
@ehuss ehuss changed the title Fix edition Add -Zfix-edition May 24, 2025
@ehuss ehuss force-pushed the fix-edition branch 2 times, most recently from 08b0aa2 to 9617f3b Compare May 24, 2025 22:33
@rustbot rustbot added the A-infrastructure Area: infrastructure around the cargo repo, ci, releases, etc. label May 24, 2025
[package]
name = "foo"
edition = "future"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change

I can't tell, is the trailing whitespace on this line intended?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it's just an artifact of how the str! macro works (which handles automatic updates). There isn't a blank line here.

Copy link

@traviscross traviscross May 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It may be the same answer, but just in case it was ambiguous, what stood out here wasn't the blank line, but that (unlike the blank lines above) the line contains 12 space characters ( ).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I see. Yea, that's a little awkward also due to defining inline. I went ahead and removed it.

@rustbot

This comment has been minimized.

@rustbot rustbot added the S-waiting-on-author Status: The marked PR is awaiting some action (such as code changes) from the PR author. label May 25, 2025
ehuss added 3 commits May 25, 2025 08:18
This factors out the code to reload a workspace since I will be needing
to reuse this elsewhere.

There is some risk with this method not getting updated correctly in the
future as new fields are added to Workspace (and it may be missing some
things now), but that is an issue with the existing code.
This adds support for parsing the `-Zfix-edition` flag.
This adds the `EditionFixMode` enum to control the behavior of
`cargo fix --edition`. The main intent is to provide a way to force
`cargo fix` to migrate to a specific edition, instead of just going to
the "next".

This will be needed for `-Zfix-edition` in order to force it to use the
"future" edition, which is never the "next" edition.

This requires being able to serialize and deserialize this setting as it
is conveyed through an environment variable to the recursive cargo
invocation.
This adds the implementation for the behavior of `cargo fix
-Zfix-edition`.
@ehuss ehuss marked this pull request as ready for review May 25, 2025 15:25
@rustbot
Copy link
Collaborator

rustbot commented May 25, 2025

r? @weihanglo

rustbot has assigned @weihanglo.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label May 25, 2025
Copy link
Member

@weihanglo weihanglo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The implementation looks reasonable with those tests. I didn't really follow closely enough to understand whether it fits edition testing's nees, but you know better than me so 👍🏾.

Feel free to merge it with or without addressing line breaking issue.

@@ -1915,6 +1916,19 @@ When new editions are introduced, the `unstable-editions` feature is required un

The special "future" edition is a home for new features that are under development, and is permanently unstable. The "future" edition also has no new behavior by itself. Each change in the future edition requires an opt-in such as a `#![feature(...)]` attribute.

## `fix-edition`

`-Zfix-edition` is a permanently unstable flag to assist with testing edition migrations, particularly with the use of crater. It only works with the `cargo fix` subcommand. It takes two different forms:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want to have any line wrap here, or follow https://sembr.org/?
I am forgetting what the style we currently adopt.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On the Reference and other documents we're just unwrapping now.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good. Thanks for the clarification. I'll merge as-is.

@weihanglo weihanglo added this pull request to the merge queue May 26, 2025
Merged via the queue into rust-lang:master with commit 6ffc01f May 26, 2025
23 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-cli Area: Command-line interface, option parsing, etc. A-documenting-cargo-itself Area: Cargo's documentation A-infrastructure Area: infrastructure around the cargo repo, ci, releases, etc. A-manifest Area: Cargo.toml issues A-unstable Area: nightly unstable support A-workspaces Area: workspaces Command-fix S-waiting-on-author Status: The marked PR is awaiting some action (such as code changes) from the PR author. S-waiting-on-review Status: Awaiting review from the assignee but also interested parties.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants